/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-17 14:00:29
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.dataperm.annotation.DataPermissionField;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_edu_trainning_record")
@SQLDelete(sql = "update wwyt_edu_trainning_record set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_edu_trainning_record set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
@Proxy(lazy = false)
@TableName("wwyt_edu_trainning_record")
public class EduTrainningRecord implements java.io.Serializable {

    // columns START
    @Id
    @GeneratedValue(strategy = IDENTITY)

    // ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    // 编码
    @Column(name = "CODE", length = 10, nullable = false)
    private String code;

    // 计划ID
    @Column(name = "TRAINNING_PLAN_ID")
    private Long trainningPlanId;

    // 培训类型ID
    @Column(name = "TRAINNING_TYPE_ID")
    private Long trainningTypeId;

    private transient Long departId;

    // 培训学时
    @Column(name = "LESSONS")
    private Double lessons;

    // 培训日期
    @Column(name = "TRAINNING_DATE")
    private java.util.Date trainningDate;

    // 培训结束日期
    @Column(name = "TRAINNING_END_DATE")
    private java.util.Date trainningEndDate;

    // 培训地点
    @Column(name = "TRAINNING_PLACE", length = 200)
    private String trainningPlace;

    // 培训单位ID
    @Column(name = "TRAINNING_DEPART_ID")
    private Long trainningDepartId;

    // 培训讲师ID
    @Column(name = "TRAINNING_TEACHER_ID")
    private Long trainningTeacherId;

    // 考核单位ID
    @Column(name = "ASSESS_DEPART_ID")
    private Long assessDepartId;

    // 培训费用
    @Column(name = "COST")
    private Double cost;

    // 培训简介
    @Column(name = "INTRODUCTION", length = 65535)
    private String introduction;

    // 是否有考试
    @Column(name = "HAS_EXAM", length = 2)
    private String hasExam;

    // 考试ID
    @Column(name = "EXAM_ID")
    private Long examId;

    // 考试及格分数
    @Column(name = "EXAM_PASS_SCORE")
    private Float examPassScore;

    // 是否有证书
    @Column(name = "HAS_CERT", length = 2)
    private String hasCert;

    // 证书ID
    @Column(name = "CERT_ID")
    private Long certId;

    // 创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    // 创建时间
    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    // 更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    // 更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private java.util.Date updateTime;

    // 删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;

    // 组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;

    // 租户
    @Column(name = "TENENT_ID")
    private Long tenentId;

    //责任部门
    @Column(name = "responsible_dept")
    @DataPermissionField(sqlColumn = "responsible_dept")
    private Integer responsibleDept;
    // columns END

    //培训名称
    @Column(name = "training_name")
    private String trainingName;

    /***
     * 附件 集合
     */
    @Column(name = "ATTACHMENTS")
    private String attachments;

    //是否开启人脸识别 0关闭 1开启
    @Column(name = "OPEN_FACE")
    private Integer openFace;

    //培训形式 0线下1线上
    @Column(name = "TRAINING_FORM")
    private Integer trainingForm;

    //是否需要签到0否1是
    @Column(name = "HAS_SIGN_IN")
    private Integer hasSignIn;

    //培训合格标准 0 完成签到，1手动录入，2考试通过，3学完课程，4学完课程+考试通过，5完成签到+考试通过
    @Column(name = "TRAINING_QUALIFIED_STANDARD")
    private Integer trainingQualifiedStandard;

    //培训发布状态 0未发布1已发布
    @Column(name = "TRAINING_PUBLISH_STATUS")
    private Integer trainingPublishStatus;

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof EduTrainningRecord == false)
            return false;
        if (this == obj)
            return true;
        EduTrainningRecord other = (EduTrainningRecord) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
